﻿package {
	import flash.utils.getTimer;
	
	import com.googlecode.milib.base.IMLBroadcasterListener;
	import com.googlecode.milib.base.MLBroadcastClass;
	import com.googlecode.milib.dbg.SimpleTrace;
	import com.googlecode.milib.service.singleton.KeyboardService;
	import com.googlecode.milib.vo.MLEventInfo;	

	/**
	 * @author Marek Brun 'minim'
	 */
	public class SomeClass extends MLBroadcastClass implements IMLBroadcasterListener {

		public var ks:KeyboardService;
		public var arr:Array;
		public var obj:Object;
		public var other:SomeOtherClass;
		private var noMilib:NoMiLibClass;

		public function SomeClass() {
			dbg.log('Hello world from SomeClass');
			arr=['one', 2, true];
			obj={str:'one', num:2, bool:true, subObj:{}};
			dbg.log('linked obj:'+dbg.link(obj));
			dbg.log('linked arr:'+dbg.link(arr));
			ks=KeyboardService.getInstance();
			ks.addListener(this);
			for(var i:String in this) {
				SimpleTrace.trace(i);
			}
			//openDBGWindow();
			
			noMilib=new NoMiLibClass();
			dbg.log('noMilib class>'+dbg.link(noMilib));
			
			other=new SomeOtherClass();
			dbg.log('other class>'+dbg.link(other));
			
		}//<>
		
		public function logHelloWorld():void {
			dbg.log('Hello World from '+dbg.link(this));
		}
		
		public function addFPSMonitorRandomTag():void {
			dbg.logFPSTag('Some random FPS tag at time '+getTimer());
		}
		
		public function addMemoryMonitorRandomTag():void {
			dbg.logMemoryTag('Some random memory tag at time '+getTimer());
		}

//********************************************************************************************
//		events for SomeClass
//********************************************************************************************
		public function onEvent(ev:MLEventInfo):void {
			switch(ev.hero){
				case ks:
					switch(ev.event) {
						case ks.event_Down:
							switch(ev.data.keyCode){
								case KeyboardService.KEY_T:
									dbg.log('abcdefghijklmno'.split('').join('\n'));
								break;
								case KeyboardService.KEY_A:
									dbg.log(String(Math.random()*99999999));
								break;
								case KeyboardService.KEY_V:
									dbg.logv('count');
									dbg.logv('randomNumber', Math.random()*99999999);
								break;
								case KeyboardService.KEY_P:
									dbg.logv('new'+int(Math.random()*100));
								break;
								case KeyboardService.KEY_O:
									dbg.openDBGWindow();
								break;
							}
						break;
					}
				break;
			}
		}//<<
		
	}
}
